

#include "unitfactory.h"
#include "ballista.h"
#include "bow.h"
#include "cannon.h"
#include "catapult.h"
#include "giantflamethrower.h"
#include "musket.h"
#include "pistol.h"
#include "spear.h"
#include "staff.h"
#include "steambehemoth.h"
#include "steamchariot.h"
#include "swordsman.h"
#include "plague_cannon.h"
#include "undead_catapult.h"


UnitFactory::UnitFactory() {

}

UnitFactory::~UnitFactory() {

}

Unit *UnitFactory::createUnit(UnitInfo const & info, float scale) {
	Unit *unit = nullptr;
	
	string name = Unit::getSkeletonFileName(info);

	if (name == CREATURE_TYPE_NAMES[(int)CreatureType::ballista]) {
		unit = new Ballista();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::pistol]) {
		unit = new Pistol();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::steam_chariot]) {
		unit = new SteamChariot();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::bow]) {
		unit = new Bowman();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::spear]) {
		unit = new Spear();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::one_hand_weapon] || name == CREATURE_TYPE_NAMES[(int)CreatureType::two_hand_weapon]) {
		unit = new Swordsman();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::cannon]) {
		unit = new Cannon();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::plague_cannon]) {
		unit = new PlagueCannon();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::giant_flamethrower]) {
		unit = new GiantFlamethrower();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::staff]) {
		unit = new Staff();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::catapult]) {
		unit = new Catapult();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::undead_catapult]) {
		unit = new UndeadCatapult();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::musket]) {
		unit = new Musket();
	} else if (name == CREATURE_TYPE_NAMES[(int)CreatureType::steam_behemoth]) {
		unit = new SteamBehemoth();
	}

	if(unit) {
		unit->init(info, scale);
	}

	return unit;
}
